import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _isEmpty from "lodash/isEmpty";

var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2;

import React from 'react';
import { Button, Col, Form, Input, Row, Select } from 'antd';
import { Bind, Throttle } from 'lodash-decorators';
import intl from 'utils/intl';
import { DEBOUNCE_TIME, FORM_COL_4_LAYOUT, SEARCH_FORM_ITEM_LAYOUT, SEARCH_FORM_ROW_LAYOUT } from 'utils/constants';
var FormItem = Form.Item;
var expandFormStyle = {
  display: ''
};
var noExpandFormStyle = {
  display: 'none'
};
var FilterForm = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Throttle(DEBOUNCE_TIME), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$PureComponent) {
  _inherits(FilterForm, _React$PureComponent);

  var _super = _createSuper(FilterForm);

  function FilterForm(props) {
    var _this;

    _classCallCheck(this, FilterForm);

    _this = _super.call(this, props); // 调用父组件 props onRef 方法

    props.onRef(_assertThisInitialized(_this));
    _this.state = {
      expandForm: false
    };
    return _this;
  }

  _createClass(FilterForm, [{
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.toggleForm.cancel();
    }
  }, {
    key: "toggleForm",
    value: function toggleForm() {
      var expandForm = this.state.expandForm;
      this.setState({
        expandForm: !expandForm
      });
    }
    /**
     * 查询操作
     */

  }, {
    key: "handleSearch",
    value: function handleSearch() {
      var _this$props = this.props,
          form = _this$props.form,
          onSearch = _this$props.onSearch;
      form.validateFields(function (err) {
        if (_isEmpty(err)) {
          onSearch(form);
        }
      });
    }
    /**
     * 重置操作
     */

  }, {
    key: "handleReset",
    value: function handleReset() {
      var form = this.props.form;
      form.resetFields();
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
          form = _this$props2.form,
          _this$props2$sourceFl = _this$props2.sourceFlagList,
          sourceFlagList = _this$props2$sourceFl === void 0 ? [] : _this$props2$sourceFl,
          _this$props2$jobStatu = _this$props2.jobStatusList,
          jobStatusList = _this$props2$jobStatu === void 0 ? [] : _this$props2$jobStatu;
      var getFieldDecorator = form.getFieldDecorator;
      var expandForm = this.state.expandForm;
      return /*#__PURE__*/React.createElement(Form, {
        className: "more-fields-search-form"
      }, /*#__PURE__*/React.createElement(Row, Object.assign({
        type: "flex",
        gutter: 24,
        align: "bottom"
      }, SEARCH_FORM_ROW_LAYOUT), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({
        label: intl.get('csdr.jobInfo.model.jobInfo.id').d('任务ID')
      }, SEARCH_FORM_ITEM_LAYOUT), getFieldDecorator('taskId', {
        rules: [{
          pattern: /^[0-9]*$/,
          message: intl.get('csdr.jobInfo.validation.digital').d('只能输入数字')
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        trim: true,
        inputChinese: false
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('csdr.jobInfo.model.jobInfo.jobCode').d('任务编码')
      }), getFieldDecorator('jobCode')( /*#__PURE__*/React.createElement(Input, {
        trim: true,
        typeCase: "upper",
        inputChinese: false
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('csdr.jobInfo.model.jobInfo.sourceFlag').d('来源标识')
      }), getFieldDecorator('sourceFlag')( /*#__PURE__*/React.createElement(Select, {
        allowClear: true
      }, sourceFlagList.map(function (item) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          label: item.meaning,
          value: item.value,
          key: item.value
        }, item.meaning);
      }))))), /*#__PURE__*/React.createElement(Col, Object.assign({}, FORM_COL_4_LAYOUT, {
        className: "search-btn-more"
      }), /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(Button, {
        onClick: this.toggleForm
      }, expandForm ? intl.get('cpaas.common.button.collected').d('收起查询') : intl.get('cpaas.common.button.viewMore').d('更多查询')), /*#__PURE__*/React.createElement(Button, {
        onClick: this.handleReset
      }, intl.get('cpaas.common.button.reset').d('重置')), /*#__PURE__*/React.createElement(Button, {
        type: "primary",
        htmlType: "submit",
        onClick: this.handleSearch
      }, intl.get('cpaas.common.button.search').d('查询'))))), /*#__PURE__*/React.createElement(Row, Object.assign({}, SEARCH_FORM_ROW_LAYOUT, {
        style: expandForm ? expandFormStyle : noExpandFormStyle
      }), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('csdr.jobInfo.model.jobInfo.jobStatus').d('状态')
      }), getFieldDecorator('jobStatus')( /*#__PURE__*/React.createElement(Select, {
        allowClear: true
      }, jobStatusList.map(function (item) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          label: item.meaning,
          value: item.value,
          key: item.value
        }, item.meaning);
      }))))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({
        label: "JobHandler"
      }, SEARCH_FORM_ITEM_LAYOUT), getFieldDecorator('jobHandler')( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('csdr.jobInfo.model.jobInfo.executorName').d('执行器')
      }), getFieldDecorator('executorName')( /*#__PURE__*/React.createElement(Input, null))))), /*#__PURE__*/React.createElement(Row, Object.assign({}, SEARCH_FORM_ROW_LAYOUT, {
        style: expandForm ? expandFormStyle : noExpandFormStyle
      }), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(FormItem, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('csdr.jobInfo.model.jobInfo.jobDesc').d('任务描述')
      }), getFieldDecorator('description')( /*#__PURE__*/React.createElement(Input, null))))));
    }
  }]);

  return FilterForm;
}(React.PureComponent), (_applyDecoratedDescriptor(_class2.prototype, "toggleForm", [_dec2, _dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "toggleForm"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleReset", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleReset"), _class2.prototype)), _class2)) || _class);
export { FilterForm as default };